package org.perla.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 */
@Entity
@Table(name = "sensori")
@NamedQueries({
    @NamedQuery(name = "Sensori.findAll", query = "SELECT s FROM Sensori s"),
    @NamedQuery(name = "Sensori.findByIdNodo", query = "SELECT s FROM Sensori s WHERE s.sensoriPK.idNodo = :idNodo"),
    @NamedQuery(name = "Sensori.findByIdSensore", query = "SELECT s FROM Sensori s WHERE s.sensoriPK.idSensore = :idSensore"),
    @NamedQuery(name = "Sensori.findByCoordn", query = "SELECT s FROM Sensori s WHERE s.coordn = :coordn"),
    @NamedQuery(name = "Sensori.findByCoorde", query = "SELECT s FROM Sensori s WHERE s.coorde = :coorde")})
public class Sensori implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SensoriPK sensoriPK;
    @Basic(optional = false)
    @Column(name = "COORDN")
    private String coordn;
    @Basic(optional = false)
    @Column(name = "COORDE")
    private String coorde;
    @JoinColumn(name = "ID_NODO", referencedColumnName = "ID_NODO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Nodo nodo;
    @JoinColumn(name = "TIPO", referencedColumnName = "ID_TIPO")
    @ManyToOne(optional = false)
    private Tiposensore tiposensore;

    public Sensori() {
    }

    public Sensori(SensoriPK sensoriPK) {
        this.sensoriPK = sensoriPK;
    }

    public Sensori(SensoriPK sensoriPK, String coordn, String coorde) {
        this.sensoriPK = sensoriPK;
        this.coordn = coordn;
        this.coorde = coorde;
    }

    public Sensori(String idNodo, String idSensore) {
        this.sensoriPK = new SensoriPK(idNodo, idSensore);
    }

    public SensoriPK getSensoriPK() {
        return sensoriPK;
    }

    public void setSensoriPK(SensoriPK sensoriPK) {
        this.sensoriPK = sensoriPK;
    }

    public String getCoordn() {
        return coordn;
    }

    public void setCoordn(String coordn) {
        this.coordn = coordn;
    }

    public String getCoorde() {
        return coorde;
    }

    public void setCoorde(String coorde) {
        this.coorde = coorde;
    }

    public Nodo getNodo() {
        return nodo;
    }

    public void setNodo(Nodo nodo) {
        this.nodo = nodo;
    }

    public Tiposensore getTiposensore() {
        return tiposensore;
    }

    public void setTiposensore(Tiposensore tiposensore) {
        this.tiposensore = tiposensore;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sensoriPK != null ? sensoriPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sensori)) {
            return false;
        }
        Sensori other = (Sensori) object;
        if ((this.sensoriPK == null && other.sensoriPK != null) || (this.sensoriPK != null && !this.sensoriPK.equals(other.sensoriPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.perla.entities.Sensori[sensoriPK=" + sensoriPK + "]";
    }

}
